/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bankowosc.polaczenie;

import bankowosc.dane.Wniosek;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author Cyga
 */
public class WniosekDB {
    public ArrayList<Wniosek> pobierzWniosek(polacz p, int id_klienta) {
		ArrayList<Wniosek> wnioski = new ArrayList<>();
              
                
               
		Statement stmt = p.getStmt();
                
		String komenda = "select * from wniosek";
                
		try {
                     
			ResultSet rs = stmt.executeQuery(komenda);
                        
			while(rs.next() )
                                {
                          //  String komenda1 = "select typ from TYP_WNIOSKU WHERE id_typ_wniosku="+rs.getInt(4);
                          //  String komenda2 = "select rezultat from REZULTAT_WNIOSKU where id_rezultat="+rs.getInt(5);
                        //ResultSet rs1 = stmt1.executeQuery(komenda1);
                      //  ResultSet rs2 = stmt2.executeQuery(komenda2);
                            System.out.println(rs.getInt(1));
				wnioski.add(new Wniosek(rs.getInt(1),rs.getInt(2),
				rs.getInt(4),rs.getInt(5),rs.getDate(3)));
                               
			}
			rs.close();
			return wnioski;
		} catch (SQLException e) {
			e.printStackTrace();
		}
                
		return null;
	}
}
